<?php
/**
 * Created by PhpStorm.
 * User: dungnt13
 * Date: 11/27/14
 * Time: 11:49 AM
 */

namespace Frontend;

use BaseController;
use Media,
    Input,
    Response,
    View,
    Redirect,
    Str;

class MediasController extends BaseController
{
    public function getImage($hash = null)
    {
        $size = Input::get('size', '');
        if ($size != "" && $size != "550x500")
            $size .= '_crop/';
        if ($size == "550x500")
            $size .= '/';
        $photo = Media::where('hash', '=', $hash)->first();
        $file = public_path() . '/' . $photo->file_path . '/' . $size . $photo->file_name;
        header("Content-type: image/jpeg");
        readfile($file);
        exit(0);
    }
} 